/*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Author: Nicolas Longuet Marx
Date: January 23 2023
Last modified: Aug 19 2023
Object: Produce figures of the main paper
Databases in input: A_experiment.dta
Databases in output: None

Figures generated in this script:

- Figure 1: Effect of randomized messages on satisfaction with policy response
	. Figure 1a: Health treatment on health evaluation
	. Figure 1b: Economic treatment on economic evaluation
- Figure 2: Effect of randomized messages on satisfaction with head of government

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ****/

set scheme s2mono
grstyle init
grstyle set plain, horizontal grid dotted

use "1_data/A_experiment.dta", replace

gen H_treat = 1 if TH2 ==1
replace H_treat = 2 if TH1 ==1 
replace H_treat = 3 if TH3 ==1 
replace H_treat = 4 if TH4 ==1 
lab var H_treat "Health treatment"

label define H_treat_lab 1 "Health good & praise gov't" 2 "Health good" 3 "Health bad" 4 "Health bad & blame gov't"
lab values H_treat H_treat_lab

gen E_treat = 1 if TE2 ==1
replace E_treat = 2 if TE1 ==1 
replace E_treat = 3 if TE3 ==1 
replace E_treat = 4 if TE4 ==1 
lab var H_treat "Economy treatment"

label define E_treat_lab 1 "Econ good & praise gov't " 2 "Econ good" 3 "Econ bad" 4 "Econ bad & blame gov't"
lab values E_treat E_treat_lab

**# Figure 1: Effect of randomized messages on satisfaction with policy response  

**# Figure 1a: Health treatment on health evaluation 
forval k = 1/3 {
	qui reg eval_sant TH2 TH1 TH3, robust

	qui lincom TH`k'
	if r(p)<=0.1 {							
		if r(p)<=0.05 {
			if r(p)<=0.01 {
				 local signilab`k' = "***"
			}
			else {
				 local signilab`k' = "**"
			}
		}
		else {
			 local signilab`k' = "*"
		}
	}
	qui lincom TH`k' + _cons
	local pos`k' = r(ub)
	di "`pos`k'" 
	di "signilab`k'" 
}
reg eval_sant TH4
qui lincom TH4 + _cons +0.002
local pos4  = r(ub)
cibar eval_sant, over1(H_treat) barc(dknavy navy midblue eltblue) ciopts(lcolor(black)) graphopts(text(`pos2' 1.1 "`signilab2'" `pos1' 2.1 "`signilab1'"  `pos3' 3.1 "`signilab3'"  ,size(large)) text(`pos4' 4.1 "(Ref)", size(small)) ytitle("Satisfaction with health measures") xlabel(1 "Health good & praise gov't" 2 "Health good" 3 "Health bad" 4 "Health bad & blame gov't", labsize(small) nogrid)  legend(off) yla(,nogrid)  yscale(range(0.48 0.53))) 

graph export "3_output/1_main_paper/Figures/Figure1a.eps",  replace 
graph export "3_output/1_main_paper/Figures/Figure1a.pdf", as(pdf) replace


**# Figure 1b: Economic treatment on economic evaluation 
forval k = 1/3 {
	qui reg eval_eco TE2 TE1 TE3, robust

	qui lincom TE`k'
	if r(p)<=0.1 {							
		if r(p)<=0.05 {
			if r(p)<=0.01 {
				 local signilab`k' = "***"
			}
			else {
				 local signilab`k' = "**"
			}
		}
		else {
			 local signilab`k' = "*"
		}
	}
	qui lincom TE`k' + _cons
	local pos`k' = r(ub)
	di "`pos`k''" 
	di "`signilab`k''" 
}
reg eval_eco TE4
qui lincom TE4 + _cons +0.002
local pos4  = r(ub)

cibar eval_eco, over1(E_treat) barc(maroon cranberry red orange) ciopts(lcolor(black)) graphopts(text(`pos2' 1.1 "`signilab2'" `pos1' 2.1 "`signilab1'"  `pos3' 3.1 "`signilab3'"  ,size(large)) text(`pos4' 4.1 "(Ref)", size(small)) ytitle("Satisfaction with health measures") xlabel(1 "Econ good & praise gov't" 2 "Econ good" 3 "Econ bad" 4 "Econ bad & blame gov't", labsize(small) nogrid)  legend(off) yla(.48(0.01).53,nogrid) yscale(range(0.48 0.53))) 
graph export "3_output/1_main_paper/Figures/Figure1b.eps",  replace 
graph export "3_output/1_main_paper/Figures/Figure1b.pdf", as(pdf) replace



**# Figure 2: Effect of randomized messages on satisfaction with head of government 
forval k = 1/4 {
	forval j = 1/4 {
		qui reg satis_head TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3, robust
	if `k'!=4 | `j'!=4 {
		
	
			qui lincom TH`k'_TE`j'
			if r(p)<=0.1 {							
				if r(p)<=0.05 {
					if r(p)<=0.01 {
						 local signilab`k'_`j' = "***"
					}
					else {
						 local signilab`k'_`j' = "**"
					}
				}
				else {
					 local signilab`k'_`j' = "*"
				}
			}
			qui lincom TH`k'_TE`j' + _cons
			local pos`k'_`j' = r(ub)+0.001
		}
	}
}
reg satis_head TH4_TE4
qui lincom TH4_TE4 + _cons +0.002
local pos4_4  = r(ub)


cibar satis_head, over1(H_treat) over2(E_treat)  barc(dknavy navy midblue eltblue) ciopts(lcolor(black)) ///
graphopts(text(`pos2_2' 1.1 "`signilab2_2'" `pos1_2' 2.1 "`signilab1_2'" `pos3_2' 3.1 "`signilab3_2'" `pos4_2' 4.1 "`signilab4_2'" ///
`pos2_1' 5.6 "`signilab2_1'" `pos1_1' 6.6 "`signilab1_1'" `pos3_1' 7.6 "`signilab3_1'" `pos4_1' 8.6 "`signilab4_1'" ///
`pos2_3' 10.2 "`signilab2_3'" `pos1_3' 11.2 "`signilab1_3'" `pos3_3' 13.2 "`signilab3_3'" `pos4_3' 14.2 "`signilab4_3'" ///
`pos2_4' 14.9 "`signilab2_4'" `pos1_4' 15.9 "`signilab1_4'" `pos3_4' 16.9 "`signilab3_4'" `pos4_4' 18 "(Ref)", size(small) ) ytitle("Satisfaction with the head of gov't", size(small))  yla(,nogrid) xla(,nogrid labsize(small))  legend(size(small) cols(1) ) )

graph export "3_output/1_main_paper/Figures/Figure2.eps",  replace 
graph export "3_output/1_main_paper/Figures/Figure2.pdf", as(pdf) replace
